/*
 * Leaves Recognition - a neuronal network based recognition of leaf images
 * Copyright (C) 2001 Jens Langner, LightSpeed Communications GbR
 *
 * LightSpeed Communications GbR
 * Lannerstrasse 1
 * 01219 Dresden
 * Germany
 * http://www.light-speed.de/
 * <Jens.Langner@light-speed.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id$
 */

package com.cortsenc.kfulles;
/*
 * Classe que representa un punt d'una fulla
 */
public class PuntFulla {

	//Inici línia
	private int x1;
	private int y1;
	//Final línia
	private int x2;
	private int y2;
	//Angles línia (Sinus i Cosinus)
	private double cos;
	private double sin;
	
	public PuntFulla(int x, int y){
		this.x1 = x;
		this.y1 = y;
	}
	
	public PuntFulla (int x1, int y1, int x2, int y2){
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
		calcCosinus();
		calcSinus();
	}

	private void calcSinus() {
		// TODO Auto-generated method stub
	    int ax, ay;
	    double hyp;

	    ax = x2-x1;
	    ay = y2-y1;

		//Calcular la hipotenusa
	    hyp = Math.sqrt(ax*ax + ay*ay);

	    if(hyp == 0.0){
	    	hyp = Math.abs(ax);
	    }

	    this.sin = ax/hyp;
	}

	private void calcCosinus() {
		// TODO Auto-generated method stub
		int ax, ay;
		double hyp;
		
		ax = x2-x1;
		ay = y2-y1;
		
		//Calcular la hipotenusa
		hyp = Math.sqrt(ax*ax + ay*ay);
		
		if(hyp == 0.0){
			this.cos = 0.0;
		}
		else{
			this.cos = ay/hyp; 
		}
	}

	public int getX1() {
		return x1;
	}

	public void setX1(int x1) {
		this.x1 = x1;
		calcCosinus();
		calcSinus();
	}

	public int getY1() {
		return y1;
	}

	public void setY1(int y1) {
		this.y1 = y1;
		calcCosinus();
		calcSinus();
	}

	public int getX2() {
		return x2;
	}

	public void setX2(int x2) {
		this.x2 = x2;
		calcCosinus();
		calcSinus();
	}

	public int getY2() {
		return y2;
	}

	public void setY2(int y2) {
		this.y2 = y2;
		calcCosinus();
		calcSinus();
	}

	public double getCos() {
		return cos;
	}

	public double getSin() {
		return sin;
	}
}
